﻿namespace KinonekoSoftware.Studio.Resources.Controls
{

    /// <summary>
    /// Converter from <see cref="double"/> value to <see cref="Math.Log10"/> <see cref="double"/> value and vice versa.
    /// </summary>
    internal sealed class DoubleToLog10Converter : ConverterBase
    {
        /// <inheritdoc />
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var val = (double)value;
            return Math.Log10(val);
        }

    }

    /// <summary>
    /// Converter that checks equality between value and parameter.
    /// </summary>
    internal sealed class EqualityToBooleanConverter : ConverterBase
    {
        /// <inheritdoc />
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return Equals(value, parameter);
        }
        
        
        public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is true)
                return parameter;
            
            throw new NotSupportedException($"{nameof(EqualityToBooleanConverter)}: Can't bind back.");
        }
    }

    /// <summary>
    /// Handler for a content size changed event.
    /// </summary>
    /// <param name="sender">Event sender.</param>
    /// <param name="newSize">New content size.</param>
    internal delegate void ContentSizeChangedHandler([System.Diagnostics.CodeAnalysis.NotNull] object sender, Size newSize);

    /// <summary>
    /// Zoom modes.
    /// </summary>
    public enum ZoomControlModes
    {
        /// <summary>
        /// The content should fill the given space.
        /// </summary>
        Fill,

        /// <summary>
        /// The content will be represented in its original size.
        /// </summary>
        Original,

        /// <summary>
        /// The content will be zoomed with a custom percent.
        /// </summary>
        Custom,
    }

    /// <summary>
    /// Zoom view modes.
    /// </summary>
    public enum ZoomViewModifierMode
    {
        /// <summary>
        /// It does nothing at all.
        /// </summary>
        None,

        /// <summary>
        /// You can pan the view with the mouse in this mode.
        /// </summary>
        Pan,

        /// <summary>
        /// You can zoom in with the mouse in this mode.
        /// </summary>
        ZoomIn,

        /// <summary>
        /// You can zoom out with the mouse in this mode.
        /// </summary>
        ZoomOut,

        /// <summary>
        /// Zooming after the user has been selected the zooming box.
        /// </summary>
        ZoomBox,
    }
}